Unable to type cast <AnonymousType#1> to <WindowsFormsApplication1.Attributes> [ C#3.0 ]

Posted by Newbie on Stack Overflow See other posts from Stack Overflow or by Newbie
Published on 2010-05-19T12:50:22Z Indexed on 2010/05/19 12:50 UTC
Read the original article Hit count: 205

Filed under:

I have

 List<Attributes> la = new List<Attributes>();
la = (from t in result
                 let t1 = t.AttributeCollection
                 from t2 in t1
                 where t2.AttributeCode.Equals(attributeType)
                 let t3 = t2.TimeSeriesData
                 from k in t3.ToList()
                 where k.Key.Equals(startDate) && k.Key.Equals(endDate)
                 select new
                 {
                     AttributeCode = attributeType,
                     TimeSeriesData = fn(k.Key, k.Value.ToString())
                 }).ToList<Attributes>();

I am getting the error:

'System.Collections.Generic.IEnumerable<AnonymousType#1>' does not contain a definition for 'ToList' and the best extension method overload 'System.Linq.Enumerable.ToList<TSource>(System.Collections.Generic.IEnumerable<TSource>)' has some invalid arguments

I understood tye error meaning but how to type cast it. I have used var and then iterating over it got the result. But without that any other way by which I can do it?

Using C# 3.0

Thanks

© Stack Overflow or respective owner

Related posts about c#3.0